package de.kiltz.foo.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import de.kiltz.foo.dao.FooDAO;
import de.kiltz.foo.domain.Foo;

public class FooServiceImpl implements FooService {

    @Autowired
	private FooDAO fooDAO;
	
	@Override
	public Foo get(Integer id) throws Exception {
		return fooDAO.getById(id);
	}

	@Override
	@Transactional
	public Foo neu(Foo f) throws Exception {
		if (f.getDatum() == null)
		{
			f.setDatum(new Date());
		}
		return fooDAO.save(f);
	}

	@Override
	@Transactional
	public List<Foo> getByText(String txt) throws Exception {
		return fooDAO.getByText(txt);
	}

	public FooDAO getFooDAO() {
		return fooDAO;
	}

	public void setFooDAO(FooDAO fooDAO) {
		this.fooDAO = fooDAO;
	}

	
}
